package com.cn.mapper;

import com.cn.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {
    /**
     * 查询所有
     * @return
     */
    @Select("select * from tb_brand")
    @ResultMap("brandMap")
    //@Results({
    //        @Result(id = true,column = "id",property = "id"),
    //        @Result(column = "ordered",property = "ordered"),
    //        @Result(column = "status",property = "status"),
    //        @Result(column = "brand_name",property = "brandName"),
    //        @Result(column = "company_name",property = "companyName"),
    //        @Result(column = "description",property = "description"),
    //        @Result(column = "id",property = "id")
    //        })
    List<Brand> selectAll();

    /**
     * 添加
     */
    @Insert("insert into tb_brand values (null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    @Select("select * from tb_brand where id = #{id}")
    @ResultMap("brandMap")
    Brand selectById(int id);

    /**
     * 修改
     */
    @Update("update tb_brand set brand_name = #{brandName},company_name=#{companyName},ordered=#{ordered},description=#{description},status=#{status} where id = #{id}")
    void update(Brand brand);

    /**
     * 删除
     */
    @Delete("delete from tb_brand where id = #{id}")
    int deleteById(Integer id);

}
